package com.ly.aps.system.provider.convertor;

import com.ly.aps.basedata.api.BaseDataApi;
import com.ly.aps.basedata.api.OrderLabourDividePrdApi;
import com.ly.aps.basedata.api.RunParamRuleApi;
import com.ly.aps.basedata.model.dto.*;
import com.ly.aps.basedata.model.vo.CapacityDiscountRunParamVO;
import com.ly.aps.mps.maindata.api.MainDataApi;
import com.ly.aps.mps.maindata.model.dto.*;
import com.stone.commons.core.model.ApiResult;
import com.stone.commons.core.model.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @description: </br>
 * ClassName: BaseParamToMap
 * @author: YangZhenfu
 * @date: 2021/7/15 14:19
 * @version: 1.0
 */
@Component
public class BaseParamToMap {

    @Autowired
    private MainDataApi mainDataApi;

    @Autowired
    private BaseDataApi baseDataApi;

    @Autowired
    private RunParamRuleApi runParamRuleApi;

    @Autowired
    private OrderLabourDividePrdApi orderLabourDividePrdApi;


    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取产品族  name : code
     * @author pengchuan
     * @date 2021-09-17 17:36:06
     */
    public Map<String, String> getProductFamilyListMap(String companyId) {
        ApiResult<List<ProductFamilyDTO>> list = orderLabourDividePrdApi.getProductFamilyList(companyId);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ProductFamilyDTO::getPrdFamilyName, ProductFamilyDTO::getPrdFamilyCode));
        }
        return map;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取产品族  code : name
     * @author pengchuan
     * @date 2021-09-17 17:36:06
     */
    public Map<String, String> getProductFamilyListByCodeMap(String companyId) {
        ApiResult<List<ProductFamilyDTO>> list = orderLabourDividePrdApi.getProductFamilyList(companyId);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ProductFamilyDTO::getPrdFamilyCode, ProductFamilyDTO::getPrdFamilyName));
        }
        return map;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取产品对应规则 key=基地+产品族 value=userid
     * @author pengchuan
     * @date 2021-09-18 10:14:12
     */
    public Map<String, String> getLabourDividePrdlMap(String companyId) {
        ApiResult<List<OrderLabourDividePrdDTO>> list = orderLabourDividePrdApi.getLabourDivideItemListAll(companyId);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(s -> s.getFfCenterCode() + s.getPrdFamilyCode(), OrderLabourDividePrdDTO::getUserId));
        }
        return map;
    }

    /**
     * @description: 获取履行中心MAP，code:value
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: YangZhenfu
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getFulfillmentCenterKeyMap(String companyId) {
        ApiResult<List<FulfillmentCenterDTO>> fulfillmentCenterList = mainDataApi.getFulfillmentCenterList(companyId, null);
        Map<String, String> fulfillmentCenterMap = new HashMap<>();
        if (fulfillmentCenterList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            fulfillmentCenterMap = fulfillmentCenterList.getData().stream().collect(Collectors.toMap(FulfillmentCenterDTO::getFfCenterCode, FulfillmentCenterDTO::getFfCenterName));
        }
        return fulfillmentCenterMap;
    }

    /**
     * @description: 获取user MAP，userid:userName
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: pengchuan
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getUserNameMap(String companyId) {
        ApiResult<List<UserDTO>> userList = mainDataApi.getUserList(companyId, Constants.Common.IS_ACTIVE_YES);
        Map<String, String> userNameMap = new HashMap<>();
        if (userList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            userNameMap = userList.getData().stream().collect(Collectors.toMap(UserDTO::getUserId, UserDTO::getUserName));
        }
        return userNameMap;
    }

    /**
     * @description: 获取user MAP，userName userid
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: pengchuan
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getUserNameKeyMap(String companyId) {
        ApiResult<List<UserDTO>> userList = mainDataApi.getUserList(companyId, Constants.Common.IS_ACTIVE_YES);
        Map<String, String> userNameMap = new HashMap<>();
        if (userList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            userNameMap = userList.getData().stream().collect(Collectors.toMap(UserDTO::getUserName, UserDTO::getUserId));
        }
        return userNameMap;
    }


    /**
     * @description: 获取user MAP，userid:userName
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: pengchuan
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getUserNameByNumberMap(String companyId) {
        ApiResult<List<UserDTO>> userList = mainDataApi.getUserList(companyId, Constants.Common.IS_ACTIVE_YES);
        Map<String, String> userNameMap = new HashMap<>();
        if (userList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            userNameMap = userList.getData().stream().collect(Collectors.toMap(UserDTO::getUserNumber, UserDTO::getUserName));
        }
        return userNameMap;
    }

    /**
     * @description: 获取user MAP，userid:userNumber
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: pengchuan
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getUserNumberMap(String companyId) {
        ApiResult<List<UserDTO>> userList = mainDataApi.getUserList(companyId, Constants.Common.IS_ACTIVE_YES);
        Map<String, String> userMap = new HashMap<>();
        if (userList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            userMap = userList.getData().stream().collect(Collectors.toMap(UserDTO::getUserId, UserDTO::getUserNumber));
        }
        return userMap;
    }

    /**
     * @description: 获取user MAP，userid:user
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: pengchuan
     * @date : 2021/7/15 13:46
     */
    public Map<String, UserDTO> getUserMap(String companyId) {
        ApiResult<List<UserDTO>> userList = mainDataApi.getUserList(companyId, Constants.Common.IS_ACTIVE_YES);
        Map<String, UserDTO> userMap = new HashMap<>();
        if (userList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            userMap = userList.getData().stream().collect(Collectors.toMap(UserDTO::getUserId, Function.identity()));
        }
        return userMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description item主信息map code：产品描述
     * @author pengchuan
     * @date 2021-07-22 09:31:21
     */
    public Map<String, String> getItemMap(String companyId,String itemCodeList) {
        ApiResult<List<ItemDTO>> list = mainDataApi.getItmeListByItemCode(companyId,itemCodeList);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ItemDTO::getItemCode, ItemDTO::getPrdDesc));
        }
        return map;
    }

    /**
     * @description: 获取产品型号 MAP，name:code
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: pengchuan
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getProductModeValueMap(String companyId) {
        ApiResult<List<ProductModeDTO>> list = baseDataApi.getProductModeList(companyId);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ProductModeDTO::getPrdModeName, ProductModeDTO::getPrdModeCode));
        }
        return map;
    }

    /**
     * @description: 获取产品型号 MAP，code:name
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: pengchuan
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getProductModeKeyMap(String companyId) {
        ApiResult<List<ProductModeDTO>> list = baseDataApi.getProductModeList(companyId);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ProductModeDTO::getPrdModeCode, ProductModeDTO::getPrdModeName));
        }
        return map;
    }

    /**
     * @description: 获取履行中心MAP，value:code
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: YangZhenfu
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getFulfillmentCenterValueMap(String companyId) {
        ApiResult<List<FulfillmentCenterDTO>> fulfillmentCenterList = mainDataApi.getFulfillmentCenterList(companyId, null);
        Map<String, String> fulfillmentCenterMap = new HashMap<>();
        if (fulfillmentCenterList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            fulfillmentCenterMap = fulfillmentCenterList.getData().stream().collect(Collectors.toMap(FulfillmentCenterDTO::getFfCenterName, FulfillmentCenterDTO::getFfCenterCode));
        }
        return fulfillmentCenterMap;
    }

    /**
     * @description: 获取产品类型MAP，code：value
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: YangZhenfu
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getProductTypeKeyMap(String companyId) {
        ApiResult<List<ProductTypeDTO>> productTypeList = baseDataApi.getProductTypeList(companyId);
        Map<String, String> productTypeMap = new HashMap<>();
        if (productTypeList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            productTypeMap = productTypeList.getData().stream().collect(Collectors.toMap(ProductTypeDTO::getPrdTypeCode, ProductTypeDTO::getPrdTypeName));
        }
        return productTypeMap;
    }

    /**
     * @description: 获取产品类型MAP，value:code
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: YangZhenfu
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getProductTypeValueMap(String companyId) {
        ApiResult<List<ProductTypeDTO>> productTypeList = baseDataApi.getProductTypeList(companyId);
        Map<String, String> productTypeMap = new HashMap<>();
        if (productTypeList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            productTypeMap = productTypeList.getData().stream().collect(Collectors.toMap(ProductTypeDTO::getPrdTypeName, ProductTypeDTO::getPrdTypeCode));
        }
        return productTypeMap;
    }

    /**
     * @description: 获取计量单位类型MAP，code：value
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: YangZhenfu
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getMeasurementUnitKeyMap(String companyId) {
        ApiResult<List<MeasurementUnitDTO>> nuitList = baseDataApi.getMeasurementUnitList(companyId);
        Map<String, String> nuiteMap = new HashMap<>();
        if (nuitList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = nuitList.getData().stream().collect(Collectors.toMap(MeasurementUnitDTO::getMamUnitCode, MeasurementUnitDTO::getMamUnitName));
        }
        return nuiteMap;
    }

    /**
     * @description: 获取计量单位类型MAP，value：code
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: YangZhenfu
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getMeasurementUnitValueMap(String companyId) {
        ApiResult<List<MeasurementUnitDTO>> nuitList = baseDataApi.getMeasurementUnitList(companyId);
        Map<String, String> nuiteMap = new HashMap<>();
        if (nuitList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = nuitList.getData().stream().collect(Collectors.toMap(MeasurementUnitDTO::getMamUnitName, MeasurementUnitDTO::getMamUnitCode));
        }
        return nuiteMap;
    }


    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取认证类别MAP，value：code
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getFfCertificationTypeValueMap(String companyId) {
        ApiResult<List<FfCertificationTypeDTO>> list = baseDataApi.getFfCertificationTypeList(companyId, Constants.Common.IS_DELETE_NO);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(FfCertificationTypeDTO::getFfCertificationName, FfCertificationTypeDTO::getFfCertificationCode));
        }
        return nuiteMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取认证类别MAP，code：value
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getFfCertificationTypeCodeMap(String companyId) {
        ApiResult<List<FfCertificationTypeDTO>> list = baseDataApi.getFfCertificationTypeList(companyId, Constants.Common.IS_DELETE_NO);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(FfCertificationTypeDTO::getFfCertificationCode, FfCertificationTypeDTO::getFfCertificationName));
        }
        return nuiteMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取发运目的地MAP，value：code
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getShippingDestinationTypeValueMap(String companyId) {
        ApiResult<List<ShippingDestinationDTO>> list = baseDataApi.getShippingDestinationList(companyId);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(ShippingDestinationDTO::getShippingDisName, ShippingDestinationDTO::getShippingDsCode));
        }
        return nuiteMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取发运目的地MAP，code： value
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getShippingDestinationTypeCodeMap(String companyId) {
        ApiResult<List<ShippingDestinationDTO>> list = baseDataApi.getShippingDestinationList(companyId);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(ShippingDestinationDTO::getShippingDsCode, ShippingDestinationDTO::getShippingDisName));
        }
        return nuiteMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取产品版型MAP，value：code
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getProductSterotypeValueMap(String companyId) {
        ApiResult<List<ProductSterotypeDTO>> list = baseDataApi.getProductSterotypeList(companyId);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(ProductSterotypeDTO::getPrdStereotypeName, ProductSterotypeDTO::getPrdStereotypeCode));
        }
        return nuiteMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取产品版型MAP，code：value
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getProductSterotypeCodeMap(String companyId) {
        ApiResult<List<ProductSterotypeDTO>> list = baseDataApi.getProductSterotypeList(companyId);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(ProductSterotypeDTO::getPrdStereotypeCode, ProductSterotypeDTO::getPrdStereotypeName));
        }
        return nuiteMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取销售团队MAP，value：code
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getSalesAreaValueMap(String companyId) {
        ApiResult<List<SalesAreaDTO>> list = mainDataApi.getSalesAreaList(companyId, Constants.Common.IS_ACTIVE_YES);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(SalesAreaDTO::getSalesAreaName, SalesAreaDTO::getSalesAreaCode));
        }
        return nuiteMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取销售团队MAP，code ：value
     * @author pengchuan
     * @date 2021-07-20 16:06:45
     */
    public Map<String, String> getSalesAreaCodeMap(String companyId) {
        ApiResult<List<SalesAreaDTO>> list = mainDataApi.getSalesAreaList(companyId, Constants.Common.IS_ACTIVE_YES);
        Map<String, String> nuiteMap = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            nuiteMap = list.getData().stream().collect(Collectors.toMap(SalesAreaDTO::getSalesAreaCode, SalesAreaDTO::getSalesAreaName));
        }
        return nuiteMap;
    }

    /**
     * @param capacityDiscountRunParamVO
     * @return Map<String, Double>
     * @description 履行中心折算产能 转map key=基地code+产品类型code+产品型号code+版型code；value=产能折算率
     * @author pengchuan
     * @date 2021-08-12 15:25:30
     */
    public Map<String, Double> getCapacityDiscountMap(CapacityDiscountRunParamVO capacityDiscountRunParamVO) {
        Map<String, Double> map = new HashMap<>();
        ApiResult<List<CapacityDiscountDTO>> runResult = runParamRuleApi.getCapacityDiscountRunParamByParamList(capacityDiscountRunParamVO);
        if (runResult.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = runResult.getData().stream().collect(Collectors.toMap(c -> c.getFfCenterCode() + c.getPrdTypeCode() + c.getPrdModeCode() + c.getPrdStereotypeCode(), CapacityDiscountDTO::getCapacityDiscountRate));
        }
        return map;
    }

    /**
     * @param capacityDiscountRunParamVO
     * @return Map<String, Double>
     * @description 履行中心折算产能 转map key=基地code；value=产能折算率
     * @author pengchuan
     * @date 2021-08-12 15:25:30
     */
    public Map<String, Double> getCapacityDiscountKeyMap(CapacityDiscountRunParamVO capacityDiscountRunParamVO) {
        Map<String, Double> map = new HashMap<>();
        ApiResult<List<CapacityDiscountDTO>> runResult = runParamRuleApi.getCapacityDiscountRunParamByParamList(capacityDiscountRunParamVO);
        if (runResult.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = runResult.getData().stream().collect(Collectors.toMap(c -> c.getFfCenterCode(), CapacityDiscountDTO::getCapacityDiscountRate));
        }
        return map;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取需求类型map key:需求类型code，value:需求类型name
     * @author pengchuan
     * @date 2021-08-23 14:29:26
     */
    public Map<String, String> getReqirementTypeMap(String companyId) {
        ApiResult<List<ReqirementTypeDTO>> list = baseDataApi.getReqirementTypeList(companyId);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ReqirementTypeDTO::getRqTypeCode, ReqirementTypeDTO::getRqTypeName));
        }
        return map;
    }

    /**
     * @description: 获取履行中心MAP，name:code
     * @param: companyId 公司ID
     * @return: Map<String, String>
     * @author: YangZhenfu
     * @date : 2021/7/15 13:46
     */
    public Map<String, String> getFulfillmentCenterNameKeyMap(String companyId) {
        ApiResult<List<FulfillmentCenterDTO>> fulfillmentCenterList = mainDataApi.getFulfillmentCenterList(companyId, null);
        Map<String, String> fulfillmentCenterMap = new HashMap<>();
        if (fulfillmentCenterList.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            fulfillmentCenterMap = fulfillmentCenterList.getData().stream().collect(Collectors.toMap(FulfillmentCenterDTO::getFfCenterName, FulfillmentCenterDTO::getFfCenterCode));
        }
        return fulfillmentCenterMap;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取所有item信息 code:info
     * @author pengchuan
     * @date 2021-09-15 13:32:50
     */
    public Map<String, ItemDTO> getItemCodeAllMap(String companyId,String itemCodeList) {
        ApiResult<List<ItemDTO>> list = mainDataApi.getItmeListByItemCode(companyId,itemCodeList);
        Map<String, ItemDTO> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ItemDTO::getItemCode, Function.identity()));
        }
        return map;
    }

    /**
     * @param companyId
     * @return Map<String, String>
     * @description 获取所有item信息 code:info
     * @author pengchuan
     * @date 2021-09-15 13:32:50
     */
    public Map<String, ItemDTO> getItemMapByCodeList(String companyId, String itemCodeList) {
        ApiResult<List<ItemDTO>> list = mainDataApi.getItmeListByItemCode(companyId, itemCodeList);
        Map<String, ItemDTO> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            map = list.getData().stream().collect(Collectors.toMap(ItemDTO::getItemCode, Function.identity()));
        }
        return map;
    }


    /**
     * 通过车间编码获取车间信息 工厂代码+车间代码：name
     *
     * @param companyId
     * @param plantCodeList
     * @return
     * @description 通过车间编码获取车间信息
     * @author YangZhenfu
     * @date 2021/9/15 15:05
     */
    public Map<String, String> getWorkShopInfoByPlantCodeMap(String companyId, String plantCodeList) {
        ApiResult<List<WorkShopInfoDTO>> list = mainDataApi.getWorkShopInfoByPlantCode(companyId, plantCodeList);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            for (WorkShopInfoDTO dto : list.getData()) {
                map.put(dto.getPlantCode() + dto.getWorkShop(), dto.getWorkShopName());
            }
        }
        return map;
    }

    /**
     * 通过车间获取编码获取产线信息  工厂代码+车间代码+产线代码：name
     *
     * @param companyId
     * @param workShopList
     * @return
     * @description 通过车间编码获取车间信息
     * @author YangZhenfu
     * @date 2021/9/15 15:05
     */
    public Map<String, String> getWorkShopLineInfoByWorkShopMap(String companyId, String workShopList) {
        ApiResult<List<WorkShopLineInfoDTO>> list = mainDataApi.getWorkShopLineInfoByWorkShopMap(companyId, workShopList);
        Map<String, String> map = new HashMap<>();
        if (list.getCode().equals(ApiResult.SUCCESSFUL_CODE)) {
            for (WorkShopLineInfoDTO dto : list.getData()) {
                map.put(dto.getPlantCode() + dto.getWorkShop() + dto.getWorkShopLine(), dto.getWorkShopLineName());
            }
        }
        return map;
    }
}
